<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="pagetop">
          <div style="width:100%">
              <div style="float:left;width:100%">
                  <table style="font-size:12px" class="table1style">
                      <tr>
                          <td>报告单元</td>
                          <td>
                              <rm-ddl-rptunit prgno="LIS132" v-model="txtrptunit" clearable filterable defaultflag="1" @change="handlerrptitemchange($event)" :appendtobody="true" visible-change:true width="263px;"></rm-ddl-rptunit>
                          </td>
                          <td>快速检索</td>
                          <td>
                              <el-input style="width:190px;" v-model="txtsearch" placeholder="代码或名称或输入码或缩写" @keyup.enter.native="initialList" v-bind:disabled="activeEditFlag" clearable>
                              </el-input>
                          </td>
                          <td>
                              <el-checkbox v-model="isinputseq" true-label="1" false-label="0" @change="handlerinputseq($event)" id="chkinputseq">手动输入打印序号</el-checkbox>
                          </td>
                      </tr>
                  </table>
              </div>
              <div style="float:left;width:100%">
                  <table style="float:right" border="0">
                      <tr>
                          <td>
                              <el-button icon="el-icon-search" @click="initialList" v-has="'PINQUERY'" type="primary">查询</el-button>
                          </td>
                          <td>
                              <el-button icon="el-icon-plus" @click="operatedata(1)" v-has="'PADD'">新增</el-button>
                          </td>
                          <td>
                              <el-button icon="el-icon-delete-solid" @click="operatedata(2)" v-has="'PDELETE'">删除</el-button>
                          </td>
                          <td>
                              <el-button icon="el-icon-document" @click="saverecord()">保存</el-button>
                          </td>
                          <td>
                              <el-button icon="el-icon-top" @click="tabledatafirst()" :disabled="isabled">首位</el-button>
                          </td>
                          <td>
                              <el-button icon="el-icon-top-right" @click="tabledataup()" :disabled="isabled">上移</el-button>
                          </td>
                          <td>
                              <el-button icon="el-icon-bottom-right" @click="tabledatadown()" :disabled="isabled">下移</el-button>
                          </td>
                          <td>
                              <el-button icon="el-icon-bottom" @click="tabledatalast()" :disabled="isabled">末位</el-button>
                          </td>
                          <td>
                              <el-button @click="batchCopyTxtRes()" v-show="showflag=='res'">批量加载文字结果</el-button>
                          </td>
                          <td>
                              <el-button @click="dialogCopyRefRes()" v-show="showflag=='ref'">复制参考值/文字结果</el-button>
                          </td>
                      </tr>
                  </table>
              </div>
          </div>
      </div>
      <div class="pagecenter">
          <rm-layout-right splitcolor="#FFFFFF" movingcolor="#CCFFFF" :splitwidth=5 :fixsize=650>
              <template v-slot:fix>
                  <!--非区域LIS模式--->
                  <div style="height:100%" v-if="!isRegLis">
                      <!--!isRegLis-->
                      <rm-layout-top splitcolor="#FFFFFF" :splitwidth=5 :fixsize=280 :canDrag=false>
                          <template v-slot:fix>
                              <div style="height:280px;">
                                  <div style="height:100%;font-size:12px">
                                      <div style="height:15px">
                                          <font color="#006699">针对当前报告单元的特定参考值</font>
                                      </div>
                                      <div style="height:calc(100% - 15px);">
                                          <div ref="xTableRptitemRefDiv" style="height:100%">
                                              <rm-rptitemref :tableData="RefValData" :key="txtreskey" prgno="LIS132" :related="related" :rptunitid="txtrptunit" :rpt_itemcode="rpt_itemcode" ref="refrptitemval" :funon="refvaldigitsmatch" :digits="digits"></rm-rptitemref>
                                          </div>
                                      </div>
                                  </div>
                              </div>
                          </template>

                          <div style="height:100%;width:100%;">
                              <div style="height:100%;font-size:12px">
                                  <div style="height:15px">
                                      <font color="#006699">当前项目默认参考值</font>
                                  </div>
                                  <div style="height:calc(100% - 15px);">
                                      <div ref="xTable2Div" style="height:100%;">
                                          <vxe-table show-overflow border ref="xTable2" height="auto" row-id="id" size="mini" :loading="loading" :select-config="{reserve: true}" :mouse-config="{selected: true}" :data.sync="DefaultRefValData" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :header-cell-class-name="headerCellClassName" header-align="center" align="center" :edit-config="{showIcon:false}">
                                              <vxe-table-column type="index" title="NO." width="40"></vxe-table-column>
                                              <vxe-table-column field="patsex" title="性别" width="40" :formatter="['formatSelect', $opt.SexOption]">
                                              </vxe-table-column>
                                              <vxe-table-column field="ageyear1" title="年龄1(岁)>=" width="86"></vxe-table-column>
                                              <vxe-table-column field="agestr1" title="年龄1" width="86"></vxe-table-column>
                                              <vxe-table-column field="ageyear2" :title="ageyear2title" width="86"></vxe-table-column>
                                              <vxe-table-column field="agestr2" title="年龄2" width="86"></vxe-table-column>
                                              <vxe-table-column field="specimen_name" title="样本类型" width="80">
                                              </vxe-table-column>
                                              <vxe-table-column key="diag_icd" field="diag_icd" title="诊断ICD" width="80px" :edit-render="{name: 'select',options:diagicdOption}">
                                              </vxe-table-column>
                                              <vxe-table-column field="physicycle" title="生理周期" width="80" :edit-render="{name:'select', options: PhysiCycleOption}">
                                              </vxe-table-column>
                                              <vxe-table-column key="deptno" field="deptno" title="科室" width="80px" :edit-render="{name: 'select',options:deptOption}">
                                              </vxe-table-column>
                                              <vxe-table-column field="ref_l" title="参考低值" width="70" header-align="center"></vxe-table-column>
                                              <vxe-table-column field="ref_h" title="参考高值" width="70" header-align="center"></vxe-table-column>
                                              <vxe-table-column field="ref_text" title="参考值显示" width="80" header-align="center"></vxe-table-column>
                                              <vxe-table-column field="autochk_l" title="自动审核低值" width="80" header-align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                                              <vxe-table-column field="autochk_h" title="自动审核高值" width="80" header-align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                                              <vxe-table-column field="redo_l" title="需复查低值" width="80" header-align="center"></vxe-table-column>
                                              <vxe-table-column field="redo_h" title="需复查高值" width="80" header-align="center"></vxe-table-column>
                                              <vxe-table-column field="seq" title="序号" width="50" header-align="center"></vxe-table-column>
                                              <template v-slot:fix>
                                                  <div style="font-size:12px;padding-top:3px;background-color:#fff;text-align:center">
                                                      <el-button @click="CopyToRptunitRef()" class="el-button--310">全部复制到报告单元的特定参考值</el-button>
                                                      <el-checkbox v-model="clearrptunitref" style="margin-left:10px;">复制前清空报告单元的特定参考值</el-checkbox>
                                                  </div>
                                              </template>
                                          </vxe-table>
                                      </div>
                                  </div>
                              </div>
                          </div>

                      </rm-layout-top>
                  </div>
                  <!--区域LIS模式--->
                  <div style="height:100%;" v-else>
                      <el-tabs type="card" style="border:1px solid #CCC" @tab-click="handleClick" v-model="activeName">
                          <el-tab-pane label="参考值" name="anchor-1">
                              <div style="height:100%">
                                  <rm-rptitemref :tableData="RefValData" :key="txtreskey" prgno="LIS132" :related="related" :rptunitid="txtrptunit" :rpt_itemcode="rpt_itemcode" ref="refrptitemval" :funon="refvaldigitsmatch" :digits="digits"></rm-rptitemref>
                              </div>
                          </el-tab-pane>
                          <el-tab-pane label="文字结果" name="anchor-2">
                              <vxe-table border height="auto" :data.sync="txtResData" size="mini" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}" show-header-overflow="tooltip" :loading="loading" :keyboard-config="keyConfig" show-overflow="tooltip" highlight-current-row highlight-hover-row resizable class="rightClass" :row-class-name="TxtresRowClassName" header-align="center" :key="txtreskey" ref="xTable4">
                                  <vxe-table-column field="rpt_itemcode" title="报告项目代码" width="90"></vxe-table-column>
                                  <vxe-table-column field="seq" title="排列顺序" width="60" :edit-render="{name:'input', autoselect: true}" align="center"></vxe-table-column>
                                  <vxe-table-column field="textvalue" title="文字结果" width="80" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                                  <vxe-table-column field="inputcode" title="快速输入码" width="80" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                                  <vxe-table-column field="result_flag" title="结果标志" show-overflow width="70" :edit-render="{name:'select', options: $opt.resultflagOption}">
                                  </vxe-table-column>
                                  <vxe-table-column field="redoflag" title="需复查标志" width="80" align="center">
                                      <template v-slot="{row}">
                                          <el-checkbox v-model="row.redoflag" true-label="1" false-label="0"></el-checkbox>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="resultkind" title="结果类别" width="70" :edit-render="{name:'select', options: $opt.resultkindOption}">
                                  </vxe-table-column>
                                  <vxe-table-column field="canautochk" title="自动审核" width="65" align="center">
                                      <template v-slot="{row}">
                                          <el-checkbox v-model="row.canautochk" true-label="1" false-label="0"></el-checkbox>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="containtext" title="包含此文字即可" width="100" align="center">
                                      <template v-slot="{row}">
                                          <el-checkbox v-model="row.containtext" true-label="1" false-label="0"></el-checkbox>
                                      </template>
                                  </vxe-table-column>
                                  <template v-slot:fix>
                                      <div style="font-size:12px;padding-top:3px;background-color:#fff;text-align:center">
                                          <el-button @click="TxtResinsertEvent('','M')" class="el-button--310">新增</el-button>
                                          <el-button @click="TxtResdeleteEvent()" class="el-button--310">删除</el-button>
                                          <el-button @click="TxtResAddPNEvent()" class="el-button--310">阴阳性</el-button>
                                          <el-button @click="TxtResCopyEvent()" class="el-button--310">复制</el-button>
                                          <el-button @click="TxtResPasteEvent()" class="el-button--310">粘贴</el-button>
                                      </div>
                                  </template>
                              </vxe-table>
                          </el-tab-pane>
                          <!-- <el-tab-pane label="特殊设置" name="anchor-3">
                              <vxe-table border height="auto" :data.sync="txtDigitsData" size="mini" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,showIcon:false}" show-header-overflow="tooltip" :loading="loading" :keyboard-local-config="keyLocalConfig" show-overflow="tooltip" highlight-current-row highlight-hover-row resizable header-align="center" ref="xTable5" :key="txtdigkey">
                                  <vxe-table-column field="dec_digits" title="小数位数" width="106" align="center" :edit-render="{name: 'select',options:$opt.dec_digitsOption}">
                                  </vxe-table-column>
                                  <vxe-table-column field="defaultval" title="默认取值" width="106" align="center" :edit-render="{name: 'input',autoselect:true}">
                                  </vxe-table-column>
                              </vxe-table>
                          </el-tab-pane> -->
                      </el-tabs>
                  </div>
              </template>
              <!--主表-->
              <div style="height:100%;width:100%;">
                  <div ref="xTableDiv" style="height:100%" class="middlecenter">
                      <vxe-table show-overflow ref="mainxTable" height="auto" :loading="mainxTableloading" :select-config="{reserve: true}" :cell-class-name="maincellClassName" :sort-config="{trigger: 'cell'}" :keyboard-local-config="keyLocalConfig" :mouse-config="{selected: true}" :data.sync="mainTableData" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe :edit-config="{trigger: 'click', mode: 'cell',showStatus: true,activeMethod:activeSeq,showIcon:false}" @current-change="currentChangeEvent">
                          <vxe-table-column type="index" title="NO." width="40" header-align="center" align="center"></vxe-table-column>
                          <vxe-table-column field="rptitemshow" title="报告项目" width="150" sortable header-align="center"></vxe-table-column>
                          <vxe-table-column field="keyitem" title="重点项目" width="60" header-align="center" align="center">
                              <template v-slot="{row}">
                                  <el-checkbox v-if="row.keyitem=='1'" checked="checked" :key="1" @change="handleChkbox(row,'keyitem')"></el-checkbox>
                                  <el-checkbox v-else @change="handleChkbox(row,'keyitem')" :key="0"></el-checkbox>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="seq" title="打印序号" width="60" sortable header-align="center" align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                          <vxe-table-column field="groupseq" title="分组序号" width="60" header-align="center" align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                          <vxe-table-column field="inputcode" title="快速输入码" width="90" header-align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                          <vxe-table-column field="unprintflag" title="打印标志" width="90" header-align="center" align="center" :edit-render="{name:'select',options: unprintflagOption}">
                          </vxe-table-column>
                          <vxe-table-column field="stopflag" title="停用" width="40" header-align="center" align="center">
                              <template v-slot="{row}">
                                  <el-checkbox v-if="row.stopflag=='1'" checked="checked" :key="1" @change="handleChkbox(row,'stopflag')"></el-checkbox>
                                  <el-checkbox v-else @change="handleChkbox(row,'stopflag')" :key="0"></el-checkbox>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="redo_rptitem" title="复查专用" width="60" header-align="center" align="center">
                              <template v-slot="{row}">
                                  <el-checkbox v-if="row.redo_rptitem=='1'" checked="checked" :key="1" @change="handleChkbox(row,'redo_rptitem')"></el-checkbox>
                                  <el-checkbox v-else @change="handleChkbox(row,'redo_rptitem')" :key="0"></el-checkbox>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="alwayscalcref" title="强制计算参考值" width="90" header-align="center" align="center">
                              <template v-slot="{row}">
                                  <el-checkbox v-if="row.alwayscalcref=='1'" checked="checked" :key="1" @change="handleChkbox(row,'alwayscalcref')"></el-checkbox>
                                  <el-checkbox v-else @change="handleChkbox(row,'alwayscalcref')" :key="0"></el-checkbox>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="testmethod" title="测试方法" width="90" header-align="center" align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                          <vxe-table-column field="hr_flag" title="结果互认" width="90" header-align="center" align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                          <vxe-table-column field="weekdays" title="检验日期（星期几）" width="120" header-align="center" align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                          <vxe-table-column field="defaultval" title="默认值" width="60" header-align="center" :edit-render="{name:'input', autoselect: true}"></vxe-table-column>
                          <vxe-table-column field="dec_digits" title="小数位数" width="106" align="center" :edit-render="{name: 'select',options:$opt.dec_digitsOption}" v-if="isRegLis">
                          </vxe-table-column>
                          <vxe-table-column field="unit" title="单位" width="60" header-align="center" :edit-render="{name:'input', autoselect: true}">
                          </vxe-table-column>
                          <vxe-table-column field="ref_text" title="参考值" width="100" header-align="center"></vxe-table-column>
                          <vxe-table-column field="ref_l" title="参考下限" width="60" header-align="center"></vxe-table-column>
                          <vxe-table-column field="ref_h" title="参考上限" width="60" header-align="center"></vxe-table-column>
                          <vxe-table-column field="rptstyleunitname" title="报告单组合名称" width="110" header-align="center" :edit-render="{name:'select', options: rptstyleUnitOption,events: {blur: rptstyleunitnameEvent}}"></vxe-table-column>
                          <vxe-table-column field="rptunitid" title="报告单元ID" width="80" header-align="center" align="center"></vxe-table-column>
                          <vxe-table-column field="autochk_l" title="自动审核低值" width="80" header-align="center"></vxe-table-column>
                          <vxe-table-column field="autochk_h" title="自动审核高值" width="80" header-align="center"></vxe-table-column>
                          <vxe-table-column field="autochkflag" title="允许自动审核" width="90" header-align="center" align="center" :formatter="formatFun">
                          </vxe-table-column>
                          <vxe-table-column field="rptstyleid" title="使用的报告单类型" width="120" header-align="center" align="center"></vxe-table-column>
                          <vxe-table-column field="vs_reqitemcode" title="对应申请项目(双击开窗)" width="170px" header-align="center">
                              <template v-slot="{row}">
                                  <el-input v-model="row.vs_reqitemname" @dblclick.native="AlertVs_reqitemcode(row)" readonly></el-input>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="rpt_itemcode" title="项目代码" width="80" header-align="center"></vxe-table-column>
                          <vxe-table-column field="rpt_itemname" title="项目名称" width="100" header-align="center"></vxe-table-column>
                          <vxe-table-column field="iteminputcode" title="项目输入码" width="90" header-align="center"></vxe-table-column>
                          <vxe-table-column field="rptunit_price" title="项目单价" width="60" header-align="center" :edit-render="{name:'input', autoselect: true}" align="right"></vxe-table-column>
                      </vxe-table>
                  </div>
              </div>
          </rm-layout-right>
      </div>

      <!--新增弹窗-->
      <el-dialog width="1100px" top="10px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="新增报告单元对照报告项目" :visible.sync="dialogTableVisible1" :destroy-on-close="true">
          <rm-pop-selrptitem @cancel="dialogTableVisible1=false;" @selitem="addrptitem" :rptUnitReportType="selectReportType"></rm-pop-selrptitem>
      </el-dialog>

      <!--对应申请项目弹窗-->
      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择对应申请项目" :visible.sync="dialogItemVisible">
          <rm-pop-common @change="vs_reqitemChange" @cancel="dialogItemVisible=false;" datatype="reqitem"></rm-pop-common>
      </el-dialog>

      <!--复制报告单元弹窗-->
      <el-dialog title="选择复制报告单元" :visible.sync="trigerCopyEvent" width="460px">
          <table style="font-size:14px;width:100%">
              <tr>
                  <td align="right">来源报告单元</td>
                  <td>
                      <el-select v-model="refcopyrptunit" placeholder="请选择" filterable clearable style="width:100%;">
                          <!-- <el-option-group v-for="group in rptunitoptions" :key="group.label" :label="group.label">
                                  <el-option v-for="(item,index) in group.options" :key="index" :label="item.label" :value="item.value">
                                      <div style="width:100%">
                                          <span style="float: left">{{ item.label }}</span>
                                          <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
                                      </div>
                                  </el-option>
                              </el-option-group> -->
                          <el-option v-for="(item,index) in rptunitoptions" :key="index" :label="item.label" :value="item.value">
                              <div style="width:100%">
                                  <span style="float: left">{{ item.label }}</span>
                                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.value }}</span>
                              </div>
                          </el-option>
                      </el-select>
                  </td>
              </tr>
          </table>
          <span slot="footer" class="dialog-footer">
              <el-button @click="CopyDataFromRptunitEvent">确 定</el-button>
              <el-button @click="trigerCopyEvent=false" :autofocus="true">取 消</el-button>
          </span>
      </el-dialog>

      <!--参考值显示-->
      <!-- <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="多行参考值显示" :visible.sync="reftext_dialog">
          <el-input type="textarea" :rows="10" placeholder="参考值显示" v-model="val_ref_text">
          </el-input>
          <div align="right" style="width:100%;margin-top:10px;">
              <el-button @click="reftext_saveevent" icon="el-icon-document">保存</el-button>
              <el-button @click="reftext_cancelevent" icon="el-icon-close">取消</el-button>
          </div>
      </el-dialog> -->
      <!--诊断ICD-->
      <!-- <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择诊断ICD" :visible.sync="dialogdiagicd">
          <rm-pop-common ref="popcom" @change="diagicdChange" @cancel="dialogdiagicd=false;" datatype="diagnose"></rm-pop-common>
      </el-dialog> -->
      <!--科室-->
      <!-- <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="请选择科室" :visible.sync="dialogdeptno">
          <rm-pop-common ref="popdept" @change="deptChange" @cancel="dialogdeptno=false;" datatype="dept"></rm-pop-common>
      </el-dialog> -->
      <!--病人年龄-->
      <!-- <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="病人年龄" ref="dialogage" :visible.sync="diaglogageVisible">
          <table class="table1style">
              <tr>
                  <td>
                      <el-input v-model="age.agenum1" type="number" style="width:80px" @change="getAgestr" @focus="ageFocus($event)"></el-input>
                  </td>
                  <td>
                      <el-radio-group v-model="age.ageunit1">
                          <el-radio :label="'Y'" @change="agenum1Change('Y')">岁</el-radio>
                          <el-radio :label="'M'" @change="agenum1Change('M')">月</el-radio>
                          <el-radio :label="'D'" @change="agenum1Change('D')">天</el-radio>
                          <el-radio :label="'H'" @change="agenum1Change('H')">小时</el-radio>
                          <el-radio :label="'F'" @change="agenum1Change('F')">分钟</el-radio>
                      </el-radio-group>
                  </td>
              </tr>
              <tr>
                  <td>
                      <el-input v-model="age.agenum2" type="number" style="width:80px" @change="getAgestr" @focus="ageFocus($event)"></el-input>
                  </td>
                  <td>
                      <el-radio-group v-model="age.ageunit2" disabled>
                          <el-radio :label="'Y'">岁</el-radio>
                          <el-radio :label="'M'">月</el-radio>
                          <el-radio :label="'D'">天</el-radio>
                          <el-radio :label="'H'">小时</el-radio>
                          <el-radio :label="'F'">分钟</el-radio>
                      </el-radio-group>
                  </td>
              </tr>
          </table>
          <div style="color:rgb(68 170 246);margin:5px">
              返回年龄：{{age.agemodel}}<br>
              可在前台病人年龄框中输入：{{age.agestr}}返回相同结果
          </div>
          <span slot="footer" class="dialog-footer">
              <el-button type="primary" @click.native="$refs.dialogage.Confirm()">确 定</el-button>
              <el-button @click.native="$refs.dialogage.Cancel()">取 消</el-button>
          </span>
      </el-dialog> -->
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
XEUtils.mixin({
  // 自定义全局的格式化处理函数
  formatSelect(cellValue, list) {
      let item = list.find((item) => item.value == cellValue);
      return item ? item.label : "";
  },
});
import RmRptitemref from "@/components/rmcompents/rmlis/RmRptitemref.vue";
export default {
  name: "LIS132",
  components: {
      RmRptitemref,
  },
  data() {
      return {
          ageyear2title: "年龄2(岁)<=",
          reportType: "",
          selectReportType: "",
          trigerCopyEvent: false,
          reftext_dialog: false,
          val_ref_text: "",
          dialog_ref_text: "",
          isRegLis: false,
          txtResData: [],
          refcopyrptunit: "", //参考值范围复制报告单元
          activeName: "anchor-1",
          rpt_itemcodestr: "", //新增时获取报告项目代码去查找参考值和文字结果，显示数据
          //  txtDigitsData: [], //小数位数
          loading: false,
          mainxTableloading: false,
          isabled: false,
          specialmodify: false,
          dialogVisible: false,
          dialogItemVisible: false,
          dialogTableVisible1: false,
          dialogDelVisible: false,
          related: {
              sexrelated: false,
              agerelated: false,
              specimenrelated: false,
              physicyclerelated: false,
              diagicdrelated: false,
              deptrelated: false,
          },
          showflag: "ref",
          activeEditFlag: false,
          txtreskey: 0,
          // txtdigkey: 0,
          txtrptunit: "",
          txtrptseq: "",
          txtsearch: "",
          buttonwidth: "",
          rpt_itemcode: "",
          rpt_unitid: "",
          message: "",
          isinputseq: "0",
          currRowIndex: 0,
          clickrow: [],
          mainTableData: [],
          DefaultRefValData: [],
          RefValData: [],
          tempData: [],
          PhysiCycleOption: [],
          specimenOption: [],
          rptstyleUnitOption: [],
          deptOption: [],
          unprintflagOption: [
              { label: "", value: "0" },
              { label: "禁止打印", value: "1" },
              { label: "打印分隔符", value: "2" },
          ],
          autochkflagOption: [
              { label: "允许", value: "1" },
              { label: "不允许", value: "0" },
          ],
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: false,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          validRules: {
              ref_l: [{ required: true, type: "number", message: "值必须为数字" }],
              ref_h: [{ required: true, type: "number", message: "值必须为数字" }],
              redo_l: [{ required: true, type: "number", message: "值必须为数字" }],
              redo_h: [{ required: true, type: "number", message: "值必须为数字" }],
              warn_l: [{ required: true, type: "number", message: "值必须为数字" }],
              warn_h: [{ required: true, type: "number", message: "值必须为数字" }],
              seq: [{ required: true, type: "number", message: "值必须为数字" }],
          },
          alertflag: true,
          rptunitoptions: [],
          diagicdOption: [],
          dialogdiagicd: false,
          diag_icdRow: {},
          dialogdeptno: false,
          unitcaneditflag: "0",
          diaglogageVisible: false,
          age: {
              agenum1: "",
              agenum2: "",
              ageunit1: "M",
              ageunit2: "D",
              agestr: "",
              agemodel: "",
          },
          txtResCopyData: [], //记录复制的文字结果
          refvaldigitsmatch: false,
          digits: "0",
          clearrptunitref: false,
      };
  },
  created() {
      this.ddlInitialList();
      this.initialList(); //初始化主列表
      this.$ddldata.IsAreaModeFun().then((r) => {
          this.isRegLis = r; //防止刷新页面导致IsAreaMode被清掉
          //区域模式下隐藏这几列
          if (this.isRegLis) {
              this.$refs.mainxTable.hideColumn(this.$refs.mainxTable.getColumnByField("ref_text"));
              this.$refs.mainxTable.hideColumn(this.$refs.mainxTable.getColumnByField("redo_l"));
              this.$refs.mainxTable.hideColumn(this.$refs.mainxTable.getColumnByField("ref_h"));
          }
      });
  },
  watch: {
      txtsearch(val) {
          if (!!val) {
              this.isabled = true;
          } else {
              this.isabled = false;
          }
      },
  },
  mounted() {},
  updated() {},
  methods: {
      // RefValeditChange(obj) {
      //     //let o_str = obj.old; //修改前字符串
      //     let n_str = obj.new; //修改后字符串
      //     let columnName = obj.p.column.property;
      //     if (columnName == "ageyear1" || columnName == "ageyear2" || columnName == "ref_l" || columnName == "ref_h" || columnName == "redo_l" || columnName == "redo_h" || columnName == "seq") {
      //         return this.$tool.onlyNumber(n_str);
      //     } else {
      //         return n_str;
      //     }
      // },
      //下拉列表初始化
      ddlInitialList() {
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS132",
                  method: "post",
                  data: {
                      action: "ddlInitialList",
                  },
              })
              .then((res) => {
                  this.PhysiCycleOption = res.dt1; //生理周期
                  this.specimenOption = res.dt2; //标本类型
                  this.rptstyleUnitOption = res.dt3; //报告单组合名称
                  this.diagicdOption = res.dt4; //诊断ICD
                  this.deptOption = res.deptOption; //科室
                  this.unitcaneditflag = res.rptunituseitemunit; //报告单元对应报告项目支持修改项目单位(1可修改，0不可修改)
                  if (res.refbyagelessuplimit == "1") this.ageyear2title = "年龄2(岁)<";
                  this.refvaldigitsmatch = res.refvaldigitsmatch == "1";
                  //if (res.list.length > 0) {
                  //复制参考值、文字结果报告单元根据医院分组
                  // res.list.forEach((item) => {
                  //     let data = res.data.filter((m) => m.hospname == item);
                  //     let option = [];
                  //     if (data.length > 0) {
                  //         data.forEach((t) => {
                  //             option.push({ value: t.rptunitid, label: t.rptunitname });
                  //         });
                  //         this.rptunitoptions.push({ label: item, options: option });
                  //     }
                  // });
                  //}
                  //复制参考值、文字结果报告单元根据医院分组
                  this.rptunitoptions = [];
                  res.data.forEach((t) => {
                      this.rptunitoptions.push({ value: t.rptunitid, label: t.rptunitname });
                  });
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      initialList() {
          //主表查询
          this.mainxTableloading = true;
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS132",
                  method: "post",
                  data: {
                      action: "query",
                      qcode: this.txtsearch,
                      rptunitid: this.txtrptunit,
                  },
              })
              .then((response) => {
                  console.log(response);
                  //控制报告单组合名称是否可以编辑
                  response.RData.Data.forEach((item) => {
                      item.rptstyleusesp = response.rptstyleusesp;
                  });
                  this.reportType = response.reporttype;
                  this.mainTableData = response.RData.Data;
                  this.HightLightQuery();
                  this.mainxTableloading = false;
              })
              .catch((e) => {
                  this.mainxTableloading = false;
                  this.$alert(e, "出错");
              });
      },
      HightLightQuery() {
          let data = this.mainTableData;
          if (data.length > 0) {
              let currRowIndex = data.findIndex((item) => item.rpt_itemcode == this.rpt_itemcode);
              if (currRowIndex == -1) currRowIndex = 0;
              let currentrow = data[currRowIndex];
              if (!!currentrow) {
                  this.selrow = currentrow; //换行保存
                  this.$refs.mainxTable.setCurrentRow(currentrow);
                  this.handchangerow(currentrow, currRowIndex);
                  setTimeout(() => {
                      this.$refs.mainxTable.scrollToRow(currentrow);
                  }, 50);
              }
          } else {
              this.clearFun();
          }
      },
      clearFun() {
          this.DefaultRefValData = [];
          this.RefValData = [];
          this.txtResData = [];
          // this.txtDigitsData = [];
          this.rpt_itemcode = "";
          this.message = "";
          this.txtreskey++;
      },
      //报告单元改变
      handlerrptitemchange(val) {
          this.txtrptunit = val;
          this.rpt_itemcode = "";
          this.RefValData = [];
          this.txtResData = [];
          this.initialList();
      },
      rptstyleunitnameEvent(e) {
          if (this.alertflag) {
              //首次提醒
              this.$alert("按住shift再单击一行，可以给这之间的所有项目填上同样的报告单格式！", "提示");
              this.alertflag = false;
          }
      },
      currentChangeEvent({ row, rowIndex }, e) {
          if (e.shiftKey) {
              //按住shift再单击一行，可以给这之间的所有项目填上同样的报告单格式
              let data = this.$refs.mainxTable.getTableData().fullData;
              let min = this.currRowIndex;
              let max = rowIndex;
              if (rowIndex < this.currRowIndex) {
                  min = rowIndex;
                  max = this.currRowIndex;
              }
              let oridata = data[this.currRowIndex]; //获取原来的值
              for (let i = min; i <= max; i++) {
                  if (max >= i) {
                      data[i].rptstyleunitname = oridata.rptstyleunitname; //在选中区域内循环赋值
                  }
              }
          }
          //this.handchangerow(row, rowIndex);
          this.wrapsave()
              .then(() => {
                  this.selrow = row;
                  this.handchangerow(row, rowIndex);
              })
              .catch((e) => {
                  this.$refs.mainxTable.setCurrentRow(this.selrow);
                  this.$pub.message(this, e, "error");
              });
      },
      handchangerow(row, rowIndex) {
          this.digits = row.dec_digits;
          this.message = row.rptitemshow;
          this.currRowIndex = rowIndex;
          this.rpt_itemcode = row.rpt_itemcode;
          this.rpt_unitid = row.rptunitid;
          this.QueryRight();
      },
      wrapsave() {
          return new Promise((s, f) => {
              let urecitemref = [];
              let urecrptitemval = [];
              let jsonstr = {
                  insertRecords: [],
                  removeRecords: [],
                  updateRecords: [],
              };
              let data = this.$refs.refrptitemval.$refs.xTableRptitemRef.tableData;
              this.$pub.ResetSeq(data, "seq");
              urecitemref = this.$refs.refrptitemval.$refs.xTableRptitemRef.getRecordset();
              if (!this.isRegLis) {
                  //非区域lis模式
                  urecrptitemval = jsonstr;
              } else {
                  urecrptitemval = this.$refs.xTable4.getRecordset(); //文字结果修改
              }

              this.$tool
                  .request({
                      url: "LIS/LIS1/LIS132",
                      method: "post",
                      data: {
                          action: "wrapsave",
                          rpt_itemcode: this.rpt_itemcode,
                          rptunitid: this.txtrptunit,
                          urecitemref: urecitemref,
                          urecrptitemval: urecrptitemval,
                      },
                  })
                  .then((response) => {
                      if (response.errcode == "1") {
                          s();
                      } else {
                          f("保存失败！" + response.errmsg);
                      }
                  })
                  .catch((e) => {
                      f(e);
                  });
          });
      },
      //对应申请项目弹窗
      AlertVs_reqitemcode(row) {
          this.clickrow = row;
          this.dialogItemVisible = true;
      },
      vs_reqitemChange(code, name) {
          this.dialogItemVisible = false;
          this.clickrow.vs_reqitemcode = code;
          this.clickrow.vs_reqitemname = name;
      },
      QueryRight() {
          //特定参考值
          this.loading = true;
          this.sexrelated = false;
          this.agerelated = false;
          this.specimenrelated = false;
          this.physicyclerelated = false;
          this.diagicdrelated = false;
          this.deptrelated = false;
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS132",
                  method: "post",
                  data: {
                      action: "querydetail",
                      rpt_itemcode: this.rpt_itemcode,
                      rptunitid: this.rpt_unitid,
                  },
              })
              .then((response) => {
                  if (!this.isRegLis) {
                      //非区域lis模式
                      this.DefaultRefValData = response.RData.Data;
                      this.RefValData = response.RData2.Data;
                  } else {
                      this.RefValData = response.RData2.Data;
                      this.txtResData = response.RData3.Data;
                      //  this.txtDigitsData = response.RData4.Data;
                  }

                  response.RData2.Cols.forEach((element) => {
                      if (element.field == "patsex") {
                          this.sexrelated = true;
                      } else if (element.field == "ageyear1" || element.field == "ageyear2") {
                          this.agerelated = true;
                      } else if (element.field == "specimen_code") {
                          this.specimenrelated = true;
                      } else if (element.field == "physicycle") {
                          this.physicyclerelated = true;
                      } else if (element.field == "diagicd") {
                          this.diagicdrelated = true;
                      } else if (element.field == "deptno") {
                          this.deptrelated = true;
                      }
                  });
                  this.related = { sexrelated: this.sexrelated, agerelated: this.agerelated, specimenrelated: this.specimenrelated, physicyclerelated: this.physicyclerelated, diagicdrelated: this.diagicdrelated, deptrelated: this.deptrelated };
                  this.txtreskey++;
                  this.loading = false;
              })
              .catch((e) => {
                  console.log("error", e);
                  this.loading = false;
              });
      },
      //保存
      saverecord() {
          if (this.txtrptunit == "") {
              this.$pub.message(this, "请选择报告单元后再保存", "warning");
              return false;
          }
          if (this.txtsearch.trim() == "") {
              //显示所有数据的情况下支持排序
              let xTable1date = this.$refs.mainxTable.getTableData().fullData; //主表修改
              xTable1date.forEach((item) => {
                  // if (item.groupseq == "") {
                  //     item.groupseq = 0;
                  // }
                  // if (item.rptstyleid == "") {
                  //     item.rptstyleid = 0;
                  // }
                  if (!item.rptunit_price) {
                      item.rptunit_price = null;
                  }
              });
              if (this.isabled) {
                  //未勾选则循环保存
                  xTable1date.sort((a, b) => {
                      let groupseq1 = a.groupseq;
                      let groupseq2 = b.groupseq;
                      if (groupseq1 != groupseq2) {
                          return a.groupseq - b.groupseq;
                      } else {
                          return a.seq - b.seq;
                      }
                  });
                  for (let i = 0, len = xTable1date.length; i < len; i++) {
                      let tempseq = (i + 1) * 10;
                      if (tempseq !== xTable1date[i].seq) {
                          xTable1date[i].seq = tempseq;
                      }
                  }
              } else {
                  //勾选则排序保存
                  // xTable1date.sort((a, b) => {
                  //     return a.groupseq - b.groupseq;
                  // });
                  for (let i = 0, len = xTable1date.length; i < len; i++) {
                      xTable1date[i].seq = (i + 1) * 10;
                  }
              }
          }

          let urec = this.$refs.mainxTable.getRecordset();
          let urecitemref = [];
          let urecrptitemval = [];
          let urecdigits = [];
          let jsonstr = {
              insertRecords: [],
              removeRecords: [],
              updateRecords: [],
          };
          // console.log("88",this.$refs.refrptitemval);
          let data = this.$refs.refrptitemval.$refs.xTableRptitemRef.tableData;
          // this.$refs.xTableRptitemRef.tableData;
          this.$pub.ResetSeq(data, "seq");
          urecitemref = this.$refs.refrptitemval.$refs.xTableRptitemRef.getRecordset();
          //this.$refs.xTableRptitemRef.getRecordset(); //特定参考值修改
          if (!this.isRegLis) {
              //非区域lis模式
              urecrptitemval = jsonstr;
          } else {
              urecrptitemval = this.$refs.xTable4.getRecordset(); //文字结果修改
          }

          const rloading = this.openLoading("正在保存数据，请稍侯！");
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS132",
                  method: "post",
                  data: {
                      action: "save",
                      utype: this.operatetype,
                      rpt_itemcode: this.rpt_itemcode,
                      rptunitid: this.txtrptunit,
                      isinputseq: this.isinputseq,
                      urec: urec,
                      urecitemref: urecitemref,
                      urecrptitemval: urecrptitemval,
                      // urecdigits: urecdigits,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.$pub.message(this, "操作成功！", "success");
                      rloading.close();
                      this.initialList();
                  } else {
                      rloading.close();
                      this.$alert("保存失败！" + response.errmsg, "信息");
                  }
              })
              .catch((e) => {
                  this.$alert(e, "信息");
                  rloading.close();
              });
      },
      operatedata(k) {
          //k=1新增，k=2删除
          if (k == 1) {
              //弹出新增框
              if (this.txtrptunit == "") {
                  this.$message.warning("请先选择报告单元");
                  return false;
              }
              // if(this.txtsearch.trim()!="") {
              //     this.$alert("注意：在快速检索条件下新增对照报告项目，打印序号可能会出现重复！","注意");
              //     //this.txtsearch="";
              //    // this.initialList();
              // }
              this.dialogTableVisible1 = true;
              this.selectReportType = this.reportType;
          } else {
              this.queryRptitemIsUsed()
                  .then((res) => {
                      if (res.isused == "1") {
                          // this.$alert("该单元的报告项目已经被<span style='color:red'>" + res.cnt + "份</span>报告使用，禁止删除！<br>最近使用该项目的报告是(只查10份以内)：" + res.reportids + "", "提示", {
                          //     dangerouslyUseHTMLString: true,
                          // });
                          this.$alert(res.msg, "提示");
                      } else {
                          var delrow = this.$refs.mainxTable.getCurrentRow();
                          if (delrow) {
                              let msg = '确定删除报告项目为 <span style="color:red">' + this.message + "</span> 的记录吗？";
                              if (!this.message) msg = "确定删除该报告项目吗？";
                              this.$confirm(msg, "提示", {
                                  dangerouslyUseHTMLString: true,
                                  confirmButtonText: "确定",
                                  cancelButtonText: "取消",
                                  type: "warning",
                              })
                                  .then(() => {
                                      this.confirmdel();
                                  })
                                  .catch(() => {});
                          } else {
                              this.$message.warning("请先选中要删除的数据！");
                              return false;
                          }
                      }
                  })
                  .catch((e) => {
                      this.$alert(e, "出错");
                  });
              // var delrow = this.$refs.mainxTable.getCurrentRow();
              // if (delrow) {
              //     let msg = '确定删除报告项目为 <span style="color:red">' + this.message + "</span> 的记录吗？";
              //     if (!this.message) msg = "确定删除该报告项目吗？";
              //     this.$confirm(msg, "提示", {
              //         dangerouslyUseHTMLString: true,
              //         confirmButtonText: "确定",
              //         cancelButtonText: "取消",
              //         type: "warning",
              //     })
              //         .then(() => {
              //             this.confirmdel();
              //         })
              //         .catch(() => {});
              // } else {
              //     this.$message.warning("请先选中要删除的数据！");
              //     return false;
              // }
          }
      },
      queryRptitemIsUsed() {
          return this.$tool.request({
              url: "LIS/LIS1/LIS132",
              method: "post",
              data: {
                  action: "queryRptitemIsUsed",
                  rpt_itemcode: this.rpt_itemcode,
                  rptunitid: this.txtrptunit,
              },
          });
      },
      confirmdel() {
          this.dialogDelVisible = false;
          try {
              let delrow = this.$refs.mainxTable.getCurrentRow();
              if (delrow) {
                  var alldatd = this.$refs.mainxTable.getTableData().fullData;
                  var rowindex = alldatd.indexOf(delrow);
                  this.$refs.mainxTable.remove(delrow);
                  let havedata = this.$refs.mainxTable.getTableData().fullData;
                  if (havedata.length > 0) {
                      if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                      let selectrow = havedata[rowindex];
                      this.$refs.mainxTable.setCurrentRow(selectrow);
                      this.handchangerow(selectrow, rowindex);
                      setTimeout(() => {
                          this.$refs.mainxTable.scrollToRow(selectrow);
                      }, 10);
                  } else {
                      this.$refs.mainxTable.setCurrentRow(null);
                      this.clearFun();
                  }
              }
          } catch (e) {
              console.log("error", e);
          }
      },
      //新增报告单元对照报告项目
      addrptitem(rptitemcodeinfos) {
          this.rpt_itemcodestr = "";
          var datarecord = this.mainTableData; //this.$refs.mainxTable.tableData;
          var seq = datarecord.length;
          let initdata = [];
          let addflag = true;
          for (var i = 0; i < rptitemcodeinfos.length; i++) {
              if (datarecord.length > 0) {
                  let fdata = datarecord.filter((item) => item.rpt_itemcode == rptitemcodeinfos[i].rpt_itemcode);
                  if (fdata.length == 0) {
                      //没找到就新增，找到就不管
                      addflag = true;
                  } else {
                      addflag = false;
                  }
              } else {
                  addflag = true;
              }
              if (addflag) {
                  seq++;
                  this.rpt_itemcodestr += rptitemcodeinfos[i].rpt_itemcode + ",";
                  let addrecord = {
                      rptitemshow: rptitemcodeinfos[i].itemcode_en + " " + rptitemcodeinfos[i].rpt_itemname,
                      keyitem: "0",
                      seq: seq * 10,
                      groupseq: "",
                      inputcode: rptitemcodeinfos[i].inputcode,
                      unprintflag: "0",
                      stopflag: "0",
                      redo_rptitem: "0",
                      alwayscalcref: "0",
                      testmethod: "",
                      hr_flag: "",
                      weekdays: "",
                      ref_text: rptitemcodeinfos[i].ref_text,
                      redo_l: rptitemcodeinfos[i].ref_l,
                      ref_h: rptitemcodeinfos[i].ref_h,
                      rptstyleunitname: "",
                      rptunitid: this.txtrptunit,
                      autochk_l: rptitemcodeinfos[i].autochk_l,
                      autochk_h: rptitemcodeinfos[i].autochk_h,
                      autochkflag: rptitemcodeinfos[i].autochkflag,
                      rptstyleid: "0",
                      vs_reqitemcode: "",
                      rpt_itemcode: rptitemcodeinfos[i].rpt_itemcode,
                      rpt_itemname: rptitemcodeinfos[i].rpt_itemname,
                      iteminputcode: "",
                      rptunit_price: null,
                      dec_digits: rptitemcodeinfos[i].dec_digits,
                      defaultval: rptitemcodeinfos[i].defaultval, 
                      unit: rptitemcodeinfos[i].unit, 
                  };
                  //  console.log("seq", addrecord.rpt_itemname + "---" + addrecord.seq);
                  initdata.push(addrecord);
              }
          }

          let len = initdata.length;
          if (len > 0) {
              this.rpt_itemcode = initdata[len - 1].rpt_itemcode;
              this.addrptitemSave(initdata);
              //console.log("777", initdata);
          }
          this.dialogTableVisible1 = false;
      },
      //addrptitemSave执行后台保存逻辑，避免增加全部项目时卡死的情况
      async addrptitemSave(initdata) {
          let urec = {
              insertRecords: initdata,
              removeRecords: [],
              updateRecords: [],
          };
          try {
              const rloading = this.openLoading("本次共新增数据" + initdata.length + "条,正在导入中，请耐心等待！");
              const response = await this.$tool.request({
                  url: "LIS/LIS1/LIS132",
                  method: "post",
                  data: {
                      action: "addrptitemSave",
                      utype: this.operatetype,
                      rpt_itemcode: this.rpt_itemcode,
                      rptunitid: this.txtrptunit,
                      isinputseq: this.isinputseq,
                      urec: urec,
                  },
              });
              if (response.errcode == "1") {
                  this.$pub.message(this, "操作成功！", "success");
                  //新增时，对于弹窗勾选的项目代码,是否存在rptuitid=0的数据,如果有，复制这份数据到选择的报告单元ID
                  //所有数据都插入后带出参考值明细和项目文字结果
                  this.$nextTick(async () => {
                      let result = await this.SaveLab_RptItemRef();
                      if (result.errcode == "-1") {
                          this.$alert("新增项目时未能带出参考值明细和项目文字结果" + result.errmsg, "提示");
                      }
                  });
                  this.initialList();
                  this.FunScrollY(2);
                  rloading.close();
              } else {
                  this.$alert("保存失败！" + response.errmsg, "信息");
                  rloading.close();
              }
          } catch (e) {
              rloading.close();
              this.$alert(e, "出错");
          }
      },
      openLoading(text) {
          const rloading = this.$loading({
              // 声明一个loading对象
              lock: true, // 是否锁屏
              text: text, // 加载动画的文字
              spinner: "el-icon-loading", // 引入的loading图标
              background: "rgba(0, 0, 0, 0.3)", // 背景颜色
              target: ".sub-main", // 需要遮罩的区域
              body: true,
              customClass: "mask", // 遮罩层新增类名
          });
          return rloading;
      },
      //确保所有数据都插入后带出参考值明细和项目文字结果的执行函数
      async SaveLab_RptItemRef() {
          if (this.txtrptunit == "") {
              this.$message.warning("请选择报告单元！");
              return false;
          }
          try {
              const response = await this.$tool.request({
                  url: "LIS/LIS1/LIS132",
                  method: "post",
                  data: {
                      action: "SaveLab_RptItemRef",
                      rptunitid: this.txtrptunit,
                      rpt_itemcodestr: this.rpt_itemcodestr,
                  },
              });
              return response;
          } catch (e) {
              console.log("error", e);
          }
      },
      //参考值明细增加
      // RefValinsertEvent() {
      //     if (this.txtrptunit == "") {
      //         this.$message.warning("请先选择报告单元！");
      //         return false;
      //     }
      //     if (this.rpt_itemcode == "") {
      //         this.$message.warning("请先选中报告项目！");
      //         return false;
      //     }
      //     let seq = 1;
      //     let seqk = 10;
      //     let oridata = this.$refs.xTableRptitemRef.tableData;
      //     let seqlist = XEUtils.max(oridata, (item) => item.seq);
      //     let maxseq = 10;
      //     if (!!seqlist) {
      //         maxseq = seqlist.seq + 10;
      //     }
      //     let initdata = {
      //         patsex: "All",
      //         ageyear1: "-1",
      //         ageyear2: "-1",
      //         specimen_code: "All",
      //         physicycle: "All",
      //         diag_icd: "All",
      //         deptno: "All",
      //         ref_l: "",
      //         ref_h: "",
      //         ref_text: "",
      //         redo_l: "",
      //         redo_h: "",
      //         warn_l: "",
      //         warn_h: "",
      //         seq: maxseq,
      //     };
      //     this.$refs.xTableRptitemRef.insert(initdata).then(({ row }) => {
      //         this.$refs.xTableRptitemRef.setCurrentRow(row);
      //         if (this.sexrelated) {
      //             this.$refs.xTableRptitemRef.setActiveCell(row, "patsex");
      //         } else if (this.agerelated) {
      //             this.$refs.xTableRptitemRef.setActiveCell(row, "ageyear1");
      //         } else if (this.specimenrelated) {
      //             this.$refs.xTableRptitemRef.setActiveCell(row, "specimen_code");
      //         } else if (this.physicyclerelated) {
      //             this.$refs.xTableRptitemRef.setActiveCell(row, "physicycle");
      //         } else if (this.diagicdrelated) {
      //             this.$refs.xTableRptitemRef.setActiveCell(row, "diag_icd");
      //         } else if (this.deptrelated) {
      //             this.$refs.xTableRptitemRef.setActiveCell(row, "deptno");
      //         } else {
      //             this.$refs.xTableRptitemRef.setActiveCell(row, "ref_l");
      //         }
      //     });
      // },
      //文字结果增加
      TxtResinsertEvent(tvalue, resultf) {
          if (this.txtrptunit == "") {
              this.$pub.message(this, "请先选择报告单元", "warning");
              return false;
          }
          if (this.rpt_itemcode == "") {
              this.$pub.message(this, "请先选中报告项目！", "warning");
              return false;
          }

          let oridata = this.$refs.xTable4.tableData;
          let seqlist = XEUtils.max(oridata, (item) => item.seq);
          let maxseq = 10;
          if (!!seqlist) {
              maxseq = seqlist.seq + 10;
          }
          let initdata = {
              rpt_itemcode: this.rpt_itemcode,
              textvalue: tvalue,
              inputcode: "",
              result_flag: resultf,
              redoflag: "",
              resultkind: "0",
              canautochk: "",
              containtext: "",
              seq: maxseq,
          };
          this.$refs.xTable4.insert(initdata).then(({ row }) => {
              this.$refs.xTable4.setActiveCell(row, "rpt_itemcode");
              this.$refs.xTable4.setCurrentRow(row);
          });
      },
      //参考值删除
      // RefValdeleteEvent() {
      //     let delrow = this.$refs.xTableRptitemRef.getCurrentRow();
      //     if (delrow) {
      //         this.$refs.xTableRptitemRef.remove(delrow);
      //         let havedata = this.$refs.xTableRptitemRef.getTableData().fullData;
      //         if (havedata.length > 0) {
      //             let selectrow = this.$refs.xTableRptitemRef.getTableData().fullData[havedata.length - 1];
      //             this.$refs.xTableRptitemRef.setCurrentRow(selectrow);
      //         } else {
      //             this.$refs.xTableRptitemRef.setCurrentRow(null);
      //         }
      //     } else {
      //         this.$pub.message(this, "请先选中要删除的明细！", "warning");
      //     }
      // },
      //文字结果删除
      TxtResdeleteEvent() {
          var delrow = this.$refs.xTable4.getCurrentRow();
          if (delrow) {
              this.$refs.xTable4.remove(delrow);
              let havedata = this.$refs.xTable4.getTableData().fullData;
              if (havedata.length > 0) {
                  let selectrow = this.$refs.xTable4.getTableData().fullData[havedata.length - 1];
                  this.$refs.xTable4.setCurrentRow(selectrow);
              }
          } else {
              this.$pub.message(this, "请先选中要删除的明细！", "warning");
          }
      },
      TxtResAddPNEvent() {
          let insertRecords = this.$refs.xTable4.getInsertRecords();
          let yangX = false;
          let yinX = false;
          let ruoyangX = false;
          //循环数据库数据 判断是否有部分数据
          for (let i = 0; i < this.txtResData.length; i++) {
              if (this.txtResData[i].textvalue.replace(/\s+/g, "") == "阴性") {
                  yinX = true;
              }
              if (this.txtResData[i].textvalue.replace(/\s+/g, "") == "阳性") {
                  yangX = true;
              }
              if (this.txtResData[i].textvalue.replace(/\s+/g, "") == "弱阳性") {
                  ruoyangX = true;
              }
          }
          //循环新添加的数据 判断是否有部分数据
          for (let i = 0; i < insertRecords.length; i++) {
              if (insertRecords[i].textvalue.replace(/\s+/g, "") == "阴性") {
                  yinX = true;
              }
              if (insertRecords[i].textvalue.replace(/\s+/g, "") == "阳性") {
                  yangX = true;
              }
              if (insertRecords[i].textvalue.replace(/\s+/g, "") == "弱阳性") {
                  ruoyangX = true;
              }
          }
          if (!yinX) {
              this.TxtResinsertEvent("阴性", "N");
          }
          if (!yangX) {
              this.TxtResinsertEvent("阳性", "P");
          }
          if (!ruoyangX) {
              this.TxtResinsertEvent("弱阳性", "Q");
          }
      },
      //复制
      TxtResCopyEvent() {
          let data = this.$refs.xTable4.tableData;
          if (data.length > 0) {
              this.txtResCopyData = this.$refs.xTable4.tableData;
              this.$pub.message(this, "已复制报告项目代码为" + this.rpt_itemcode + "的页面所有文字结果！", "success");
          } else {
              this.$alert("当前报告项目无可复制的文字结果！", "提示");
          }
      },
      //粘贴
      TxtResPasteEvent() {
          if (this.txtrptunit == "") {
              this.$pub.message(this, "请先选择报告单元", "warning");
              return false;
          }
          if (this.rpt_itemcode == "") {
              this.$pub.message(this, "请先选中报告项目！", "warning");
              return false;
          }
          let len = this.txtResCopyData.length;
          if (len > 0) {
              for (let index = 0; index < len; index++) {
                  const element = this.txtResCopyData[index];
                  let oridata = this.$refs.xTable4.tableData;
                  let seqlist = XEUtils.max(oridata, (item) => item.seq);
                  let maxseq = 10;
                  if (!!seqlist) {
                      maxseq = seqlist.seq + 10;
                  }
                  let initdata = {
                      rpt_itemcode: this.rpt_itemcode,
                      textvalue: element.textvalue,
                      inputcode: element.inputcode,
                      result_flag: element.result_flag,
                      redoflag: element.redoflag,
                      resultkind: element.resultkind,
                      canautochk: element.canautochk,
                      containtext: element.containtext,
                      seq: maxseq,
                  };
                  this.$refs.xTable4.insert(initdata).then(({ row }) => {
                      this.$refs.xTable4.setActiveCell(row, "rpt_itemcode");
                      this.$refs.xTable4.setCurrentRow(row);
                  });
              }
          }
      },
      //参考值新增与修改颜色区别
      RefRowClassName({ row, rowIndex }) {
          let isDirty = this.$refs.xTableRptitemRef.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTableRptitemRef.hasRowInsert(row)) return "row-new";
      },
      //文字结果颜色
      TxtresRowClassName({ row, column }) {
          let isDirty = this.$refs.xTable4.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTable4.hasRowInsert(row)) return "row-new";
          if (["H", "P"].includes(row.result_flag)) {
              return "row-HP";
          } else if (row.result_flag == "L") {
              return "row-L";
          } else if (row.result_flag == "Q") {
              return "row-Q";
          } else if (row.result_flag == "E") {
              return "row-E";
          } else {
              //M,N
              return "";
          }
      },
      handleChkbox(row, column) {
          let stat = row[column];
          row[column] = stat == "1" ? 0 : 1;
      },
      tabledataup() {
          var _this = this;
          let Robj = this.$table.tabledataup(this.$refs.mainxTable, this.currRowIndex, _this);
          this.currRowIndex = Robj.currRowIndex;
          this.FunScrollY(3);
          // if (this.currRowIndex > 0) {
          //     let upData = this.$refs.mainxTable.tableData[this.currRowIndex - 1];
          //     let currentrow = this.$refs.mainxTable.tableData[this.currRowIndex];
          //     this.$refs.mainxTable.tableData.splice(this.currRowIndex - 1, 1);
          //     this.$refs.mainxTable.tableData.splice(this.currRowIndex, 0, upData);
          //     this.currRowIndex = this.currRowIndex - 1;
          // this.$nextTick(() => {
          //     this.$refs.mainxTable.setCurrentRow(currentrow);
          // });
          // }
      },
      tabledatadown() {
          var _this = this;
          let Robj = this.$table.tabledatadown(this.$refs.mainxTable, this.currRowIndex, _this);
          this.currRowIndex = Robj.currRowIndex;
          this.FunScrollY(4);
          // if (this.currRowIndex !== this.$refs.mainxTable.tableData.length - 1) {
          //     let downData = this.$refs.mainxTable.tableData[this.currRowIndex + 1];
          //     let currentrow = this.$refs.mainxTable.tableData[this.currRowIndex];
          //     this.$refs.mainxTable.tableData.splice(this.currRowIndex + 1, 1);
          //     this.$refs.mainxTable.tableData.splice(this.currRowIndex, 0, downData);
          //     this.currRowIndex = this.currRowIndex + 1;
          //     this.$nextTick(() => {
          //         this.$refs.mainxTable.setCurrentRow(currentrow);
          //     });
          // }
      },
      tabledatalast() {
          var _this = this;
          let Robj = this.$table.tabledatalast(this.$refs.mainxTable, this.currRowIndex, _this);
          this.currRowIndex = Robj.currRowIndex;
          this.FunScrollY(2);
          // if (this.currRowIndex != this.$refs.mainxTable.tableData.length - 1) {
          //     let lastData = this.$refs.mainxTable.tableData[this.currRowIndex];
          //     this.$refs.mainxTable.tableData.splice(this.currRowIndex, 1);
          //     this.$refs.mainxTable.tableData.splice(this.$refs.mainxTable.tableData.length, 0, lastData);
          //     this.currRowIndex = this.$refs.mainxTable.tableData.length - 1;
          //     this.$nextTick(() => {
          //         this.$refs.mainxTable.setCurrentRow(lastData);
          //     });
          // }
      },
      tabledatafirst() {
          var _this = this;
          let Robj = this.$table.tabledatafirst(this.$refs.mainxTable, this.currRowIndex, _this);
          this.currRowIndex = Robj.currRowIndex;
          this.FunScrollY(1);
          // if (this.currRowIndex > 0) {
          //     let firstData = this.$refs.mainxTable.tableData[this.currRowIndex];
          //     this.$refs.mainxTable.tableData.splice(this.currRowIndex, 1);
          //     this.$refs.mainxTable.tableData.splice(0, 0, firstData);
          //     this.currRowIndex = 0;
          //     this.$nextTick(() => {
          //         this.$refs.mainxTable.setCurrentRow(firstData);
          //     });
          // }
      },
      FunScrollY(index) {
          //1首未2末位3选中行位置
          let alldataLen = this.$refs.mainxTable.getTableData().fullData.length;
          let rowindex = 0;
          if (index == 1) rowindex = 0;
          else if (index == 2) rowindex = alldataLen - 1;
          else rowindex = this.currRowIndex;
          setTimeout(() => {
              let row = this.$refs.mainxTable.getTableData().fullData[rowindex];
              this.$refs.mainxTable.scrollToRow(row);
              this.currRowIndex = rowindex;
          }, 50);

          // if (index == 1) {
          //     setTimeout(() => {
          //         let L = this.$refs.mainxTable.getTableData().fullData[0];
          //         this.$refs.mainxTable.scrollToRow(L);
          //         this.currRowIndex = 0;
          //     }, 50);
          // } else if (index == 2) {
          //     setTimeout(() => {
          //         let L = this.$refs.mainxTable.getTableData().fullData[alldataLen - 1];
          //         this.$refs.mainxTable.scrollToRow(L);
          //         this.currRowIndex = alldataLen - 1;
          //     }, 50);
          // } else {
          //     let L = this.$refs.mainxTable.getTableData().fullData[this.currRowIndex];
          //     setTimeout(() => {
          //         this.$refs.mainxTable.scrollToRow(L);
          //     }, 50);
          // }
      },
      reqitemchange(code, row) {
          row.vs_reqitemcode = code;
      },
      //手动输入打印序号的checkbox改变
      handlerinputseq(e) {
          if (e == "0") {
              this.activeEditFlag = false;
              this.isabled = false;
          } else {
              this.activeEditFlag = true;
              this.isabled = true;
              this.txtsearch = "";
              this.initialList();
          }
      },
      maincellClassName({ row, column }) {
          let columnArr = ["keyitem", "seq", "groupseq", "inputcode", "unprintflag", "stopflag", "redo_rptitem", "alwayscalcref", "testmethod", "hr_flag", "weekdays", "vs_reqitemcode", "rptunit_price", "defaultval", "dec_digits", "unit"];
          if (columnArr.includes(column.property)) {
              if (column.property == "seq") {
                  if (this.activeEditFlag) {
                      return "";
                  } else {
                      return "col-gray";
                  }
              } else if (column.property == "stopflag") {
                  if (row.stopflag === 1) {
                      return "col-Pink";
                  }
              } else if (column.property == "unit") {
                  if (this.unitcaneditflag == "1") {
                      return "";
                  } else {
                      return "col-gray";
                  }
              } else {
                  return "";
              }
          } else {
              if (column.property == "rptitemshow") {
                  //报告项目名称
                  if (row.keyitem == "1") {
                      return "col-black";
                  }
              } else if (column.property == "rptstyleunitname") {
                  //报告单组合名称
                  if (row.rptstyleusesp == "1") {
                      return "";
                  } else {
                      return "col-gray";
                  }
              } else {
                  return "col-gray";
              }
          }
      },
      activeSeq({ row, column }) {
          if (column.property == "seq") {
              if (this.activeEditFlag) {
                  return true;
              } else {
                  return false;
              }
          } else if (column.property == "unit") {
              if (this.unitcaneditflag == "1") {
                  return true;
              } else {
                  return false;
              }
          } else {
              if (column.property == "rptstyleunitname") {
                  if (row.rptstyleusesp == "1") {
                      return true;
                  } else {
                      return false;
                  }
              } else {
                  return true;
              }
          }
      },
      formatFun({ cellValue, column }) {
          if (column.property == "autochkflag") {
              if (cellValue == "1") {
                  return "允许";
              } else {
                  return "不允许";
              }
          } else {
              return cellValue;
          }
      },

      handleClick(tab, evt) {
          if (tab.name == "anchor-1") {
              this.showflag = "ref";
          } else if (tab.name == "anchor-2") {
              this.showflag = "res";
          } else {
              this.showflag = "";
          }
          this.txtreskey++;
          // this.txtdigkey++;
      },
      //选择来源报告单元复制数据
      CopyDataFromRptunitEvent() {
          if (this.refcopyrptunit == "") {
              this.$message.warning("请选择要复制的报告单元！");
              return false;
          }
          const rloading = this.openLoading("正在复制数据，请稍候！");
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS132",
                  method: "post",
                  data: {
                      action: "CopyDataFromRptunitEvent",
                      rptunitid: this.txtrptunit,
                      cprptunitid: this.refcopyrptunit,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.$pub.message(this, "复制成功", "success");
                      this.initialList();
                  } else {
                      this.$alert("复制失败！" + response.errmsg, "提示");
                  }
                  rloading.close();
                  this.trigerCopyEvent = false;
              })
              .catch((e) => {
                  rloading.close();
                  this.$alert(e, "出错");
              });
      },
      //批量加载文字结果
      batchCopyTxtRes() {
          if (this.txtrptunit == "") {
              this.$pub.message(this, "请选择报告单元！", "warning");
              return false;
          }
          const rloading = this.openLoading("正在加载文字结果，请稍候！");
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS132",
                  method: "post",
                  data: {
                      action: "batchCopyTxtRes",
                      rptunitid: this.txtrptunit,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.$message.success("批量加载文字结果成功");
                      this.initialList();
                  } else {
                      this.$message.error("批量加载文字结果失败！" + response.errmsg);
                  }
                  rloading.close();
              })
              .catch((e) => {
                  this.$alert(e, "出错");
                  rloading.close();
              });
      },
      // activeMethod({ row, column }) {
      // if (column.property == "patsex") {
      //     if (this.sexrelated) {
      //         return true;
      //     } else {
      //         return false;
      //     }
      // }
      // if (column.property == "specimen_code") {
      //     if (this.specimenrelated) {
      //         return true;
      //     } else {
      //         return false;
      //     }
      // }
      // if (column.property == "physicycle") {
      //     if (this.physicyclerelated) {
      //         return true;
      //     } else {
      //         return false;
      //     }
      // }
      // if (column.property == "diag_icd") {
      //     if (this.diagicdrelated) {
      //         return true;
      //     } else {
      //         return false;
      //     }
      // }
      // if (column.property == "deptno") {
      //     if (this.deptrelated) {
      //         return true;
      //     } else {
      //         return false;
      //     }
      // }
      // if (["ageyear1", "ageyear2"].includes(column.property)) {
      //     if (this.agerelated) {
      //         return true;
      //     } else {
      //         return false;
      //     }
      // }
      // if (column.property == "seq") {
      //     return true;
      // } else {
      //     return true;
      // }
      // },
      // cellClassName({ row, rowIndex, column, columnIndex }) {
      //     if (column.property === "patsex") {
      //         if (!this.sexrelated) {
      //             return this.$pub.diseditcolumn();
      //         }
      //     }
      //     if (column.property == "physicycle") {
      //         if (!this.physicyclerelated) {
      //             return this.$pub.diseditcolumn();
      //         }
      //     }
      //     if (column.property == "diag_icd") {
      //         if (!this.diagicdrelated) {
      //             return this.$pub.diseditcolumn();
      //         }
      //     }
      //     if (column.property == "deptno") {
      //         if (!this.deptrelated) {
      //             return this.$pub.diseditcolumn();
      //         }
      //     }
      //     if (column.property == "specimen_code") {
      //         if (!this.specimenrelated) {
      //             return this.$pub.diseditcolumn();
      //         }
      //     }
      //     if (["ageyear1", "ageyear2"].includes(column.property)) {
      //         if (!this.agerelated) {
      //             return this.$pub.diseditcolumn();
      //         } else {
      //             return "";
      //         }
      //     }
      // },
      // ref_lh_Change({ row, column }, $event) {
      //     //   console.log("111",$event);
      //     let arr = ["ref_l", "ref_h"];
      //     if (arr.includes(column.property)) {
      //         if (!!row.ref_l && !!row.ref_h) {
      //             let reftxt = parseFloat(row.ref_l) + "--" + parseFloat(row.ref_h);
      //             this.$nextTick(() => {
      //                 row.ref_text = reftxt;
      //             });
      //         } else {
      //             if (!!row.ref_l && !row.ref_h) {
      //                 row.ref_text = "≥" + parseFloat(row.ref_l);
      //             }
      //             if (!row.ref_l && !!row.ref_h) {
      //                 row.ref_text = "≤" + parseFloat(row.ref_h);
      //             }
      //             if (!row.ref_l && !row.ref_h) {
      //                 row.ref_text = "";
      //             }
      //         }
      //     } else if (column.property == "ageyear1") {
      //         if (!!row.ageyear1 && Number(row.ageyear1) != -1) {
      //             this.GetPatBirthAge(row.ageyear1)
      //                 .then((res) => {
      //                     console.log(res);
      //                     row.ageyear1 = res;
      //                     //  row.ageyear1str = res.Item1.replace("y","岁");
      //                 })
      //                 .catch((e) => {
      //                     // row.ageyear1 = "-1";
      //                 });
      //         } else {
      //             row.ageyear1 = "-1";
      //         }
      //     } else if (column.property == "ageyear2") {
      //         if (!!row.ageyear2 && Number(row.ageyear2) != -1) {
      //             this.GetPatBirthAge(row.ageyear2)
      //                 .then((res) => {
      //                     console.log(res);
      //                     row.ageyear2 = res;
      //                     //  row.ageyear1str = res.Item1.replace("y","岁");
      //                 })
      //                 .catch((e) => {
      //                     // row.ageyear2 = "-1";
      //                 });
      //         } else {
      //             row.ageyear2 = "-1";
      //         }
      //     }
      // },
      // GetPatBirthAge(agestr) {
      //     return this.$tool.request({
      //         url: "LIS/LIS1/LIS132",
      //         method: "post",
      //         data: {
      //             action: "GetPatBirthAge",
      //             agestr: agestr,
      //         },
      //     });
      // },
      //双击开窗
      // dblclickdialog({ row, column }) {
      //     if (column.property == "ref_text") {
      //         //弹窗显示多行参考值的文本编辑
      //         this.dialog_ref_text = row;
      //         let refval = row.ref_text;
      //         this.val_ref_text = "";
      //         let k = "";
      //         if (!!refval) {
      //             k = refval.split("|");
      //             this.val_ref_text = k.join("\n");
      //         }
      //         this.reftext_dialog = true;
      //     } else if (column.property == "diag_icd") {
      //         //诊断icd双击开窗
      //         if (this.diagicdrelated) {
      //             this.diag_icdRow = row;
      //             this.dialogdiagicd = true;
      //         }
      //     } else if (column.property == "deptno") {
      //         if (this.deptrelated) {
      //             this.diag_icdRow = row;
      //             this.dialogdeptno = true;
      //         }
      //     } else if (["ageyear1", "ageyear2"].includes(column.property)) {
      //         this.age.agenum1 = "";
      //         this.age.agenum2 = "";
      //         this.age.ageunit1 = "M";
      //         this.age.ageunit2 = "D";
      //         this.age.agestr = "";
      //         this.age.agemodel = "";
      //         this.ageShowDialog(row, column);
      //     }
      // },
      // ageShowDialog(row, column) {
      //     this.$refs.dialogage
      //         .ShowDialog()
      //         .then(() => {
      //             if (this.age.agenum1 == "") {
      //                 this.ageShowDialog(row, column);
      //                 this.$alert("请输入一级年龄！", "提示");

      //                 return false;
      //             }

      //             if (column.property == "ageyear1") {
      //                 if (!!this.age.agenum1 && Number(this.age.agenum1) != -1) {
      //                     this.getAgestr();
      //                     this.GetPatBirthAge(this.age.agestr)
      //                         .then((res) => {
      //                             row.ageyear1 = res;
      //                         })
      //                         .catch((e) => {
      //                             //row.ageyear1 = "-1";
      //                         });
      //                 } else {
      //                     //row.ageyear1 = "-1";
      //                 }
      //             } else if (column.property == "ageyear2") {
      //                 if (!!this.age.agenum1 && Number(this.age.agenum1) != -1) {
      //                     this.getAgestr();
      //                     this.GetPatBirthAge(this.age.agestr)
      //                         .then((res) => {
      //                             row.ageyear2 = res;
      //                         })
      //                         .catch((e) => {
      //                             // row.ageyear2 = "-1";
      //                         });
      //                 } else {
      //                     //row.ageyear2 = "-1";
      //                 }
      //             }
      //         })
      //         .catch(() => {
      //             console.log("catch");
      //         });
      // },
      // getAgestr() {
      //     if (this.age.ageunit1 != this.age.ageunit2) {
      //         if (this.age.agenum1 != "") {
      //             this.age.agestr = this.age.agenum1 + this.age.ageunit1;
      //         }
      //         if (this.age.agenum2 != "") {
      //             this.age.agestr += this.age.agenum2 + this.age.ageunit2;
      //         }
      //     } else {
      //         this.age.agestr = this.age.agenum1 + this.age.ageunit1;
      //         this.age.agenum2 = "";
      //     }
      //     this.age.agestr = this.age.agestr.toLowerCase();
      //     this.age.agemodel = this.age.agestr.toLowerCase().replace("y", "岁").replace("m", "月").replace("d", "天").replace("h", "小时").replace("f", "分钟");
      // },
      //多行参考值文本编辑闭窗赋值
      // reftext_saveevent() {
      //     let temp = this.val_ref_text.split("\n");
      //     if (temp.length > 0) {
      //         temp = temp.filter((item) => item);
      //         this.dialog_ref_text.ref_text = temp.join("|");
      //     } else {
      //         this.dialog_ref_text.ref_text = this.val_ref_text;
      //     }
      //     this.reftext_dialog = false;
      // },
      //诊断ICD闭窗赋值
      // diagicdChange(code, name, row) {
      //     this.diag_icdRow.diag_icd = row.ICD10编码;
      //     this.dialogdiagicd = false;
      //     //this.$refs.xTableRptitemRef.updateListenter();
      // },
      //科室相关修改
      // deptChange(code, name, row) {
      //     this.diag_icdRow.deptno = code;
      //     this.dialogdeptno = false;
      // },
      //参考值文字结果取消弹窗
      // reftext_cancelevent() {
      //     this.reftext_dialog = false;
      // },
      //复制参考值/文字结果
      dialogCopyRefRes() {
          if (this.txtrptunit == "") {
              this.$pub.message(this, "请先选择报告单元！", "warning");
              return false;
          }
          this.trigerCopyEvent = true;
      },
      headerCellClassName({ column, columnIndex }) {
          if (["autochk_l", "autochk_h"].includes(column.property)) {
              return "col-blue";
          }
      },
      CopyToRptunitRef() {
          let refvaldata = this.$refs.refrptitemval.$refs.xTableRptitemRef.tableData;
          let defaultrefvaldata = this.$refs.xTable2.tableData;
          if (defaultrefvaldata.length > 0) {
              if (refvaldata.length > 0) {
                  // 清除报告单元参考值
                  if (this.clearrptunitref) {
                      this.$refs.refrptitemval.$refs.xTableRptitemRef.tableData = [];
                      defaultrefvaldata.forEach((item) => {
                          let updateitem = XEUtils.clone(item, true);
                          updateitem.rptunitid = this.txtrptunit;
                          this.$refs.refrptitemval.$refs.xTableRptitemRef.insert(item);
                      });
                  } else {
                      let refdata = XEUtils.clone(refvaldata, true);
                      let hasrepeatflag = false;
                      let updateitem = {};
                      defaultrefvaldata.forEach((item1) => {
                          refdata.forEach((item2) => {
                              if (item1.rpt_itemcode == item2.rpt_itemcode && item1.patsex == item2.patsex && item1.ageyear1 == item2.ageyear1 && item1.ageyear2 == item2.ageyear2 && item1.specimen_code == item2.specimen_code && item1.physicycle == item2.physicycle && item1.diag_icd == item2.diag_icd && item1.deptno == item2.deptno) {
                                  hasrepeatflag = true;
                              }
                          });
                      });

                      if (hasrepeatflag) {
                          this.$confirm("有重复的参考值，是直接覆盖还是跳过该参考值？", "提示", {
                              dangerouslyUseHTMLString: true,
                              confirmButtonText: "直接覆盖",
                              cancelButtonText: "直接跳过",
                              type: "warning",
                          })
                              .then(() => {
                                  defaultrefvaldata.forEach((item1) => {
                                      let isrepeat = false;
                                      updateitem = XEUtils.clone(item1, true);
                                      updateitem.rptunitid = this.txtrptunit;
                                      refdata.forEach((item2, index) => {
                                          if (item1.rpt_itemcode == item2.rpt_itemcode && item1.patsex == item2.patsex && item1.ageyear1 == item2.ageyear1 && item1.ageyear2 == item2.ageyear2 && item1.specimen_code == item2.specimen_code && item1.physicycle == item2.physicycle && item1.diag_icd == item2.diag_icd && item1.deptno == item2.deptno) {
                                              refvaldata[index].autochk_l = updateitem.autochk_l;
                                              refvaldata[index].autochk_h = updateitem.autochk_h;
                                              refvaldata[index].ref_l = updateitem.ref_l;
                                              refvaldata[index].ref_h = updateitem.ref_h;
                                              refvaldata[index].ref_text = updateitem.ref_text;
                                              refvaldata[index].redo_l = updateitem.redo_l;
                                              refvaldata[index].redo_h = updateitem.redo_h;
                                              refvaldata[index].seq = updateitem.seq;
                                              isrepeat = true;
                                          }
                                      });
                                      if (!isrepeat) {
                                          this.$refs.refrptitemval.$refs.xTableRptitemRef.insert(updateitem);
                                      }
                                  });
                              })
                              .catch(() => {
                                  defaultrefvaldata.forEach((item1) => {
                                      let isrepeat = false;
                                      updateitem = XEUtils.clone(item1, true);
                                      updateitem.rptunitid = this.txtrptunit;
                                      refdata.forEach((item2) => {
                                          if (item1.rpt_itemcode == item2.rpt_itemcode && item1.patsex == item2.patsex && item1.ageyear1 == item2.ageyear1 && item1.ageyear2 == item2.ageyear2 && item1.specimen_code == item2.specimen_code && item1.physicycle == item2.physicycle && item1.diag_icd == item2.diag_icd && item1.deptno == item2.deptno) {
                                              isrepeat = true;
                                          }
                                      });
                                      if (!isrepeat) {
                                          this.$refs.refrptitemval.$refs.xTableRptitemRef.insert(updateitem);
                                      }
                                  });
                              });
                      }
                  }
              } else {
                  defaultrefvaldata.forEach((item) => {
                      let updateitem = XEUtils.clone(item, true);
                      updateitem.rptunitid = this.txtrptunit;
                      this.$refs.refrptitemval.$refs.xTableRptitemRef.insert(updateitem);
                  });
              }
          } else {
              this.$alert("无可复制的参考值！");
          }
      },
      // ageFocus(event) {
      //     event.currentTarget.select();
      // },
      // agenum1Change(flag) {
      //     switch (flag) {
      //         case "Y":
      //             this.age.ageunit2 = "M";
      //             break;
      //         case "M":
      //             this.age.ageunit2 = "D";
      //             break;
      //         case "D":
      //             this.age.ageunit2 = "H";
      //             break;
      //         case "H":
      //             this.age.ageunit2 = "F";
      //             break;
      //         default:
      //             this.age.ageunit2 = "F";
      //     }
      //     this.getAgestr();
      // },
  },
};
</Script>

<style scoped>
.pagetop {
  left: 0;
  right: 0;
  height: 70px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: solid 1px #ccc;
  position: absolute;
  z-index: 99;
  text-align: left;
}
.pagebottom {
  width: 100%;
  height: 0px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: left;
  position: absolute;
  bottom: 0px;
  font-size: 12px;
  border: solid 1px #ccc;
}
.pagecenter {
  position: absolute;
  top: 75px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}
.middle-center {
  position: absolute;
  height: 100%;
  right: 484px;
  left: 0;
}

.middle-right {
  position: absolute;
  top: 0;
  bottom: 0;
  overflow: visible;
  width: 480px;
  right: 0px;
}
.table1style tr td {
  padding: 0px 2px 0px 5px;
}
::V-deep .vxe-table .vxe-body--column.col-gray {
  background-color: #f8f8f8;
}
::V-deep .vxe-table .vxe-body--column.col-black {
  color: #000000;
  font-weight: 800;
}
::V-deep .vxe-table .vxe-body--column.col-Pink {
  background-color: Pink;
}
::V-deep.middlecenter tr td div .el-input__inner {
  border: 1px solid rgba(255, 254, 254, 0) !important;
  background-color: rgba(255, 254, 254, 0) !important;
}
::V-deep.middle-right tr td div .el-input__inner {
  border: 1px solid rgba(255, 254, 254, 0) !important;
  background-color: rgba(255, 254, 254, 0) !important;
}
::V-deep .rightClass .vxe-body--row.row-new {
  color: #cc6600;
}
::V-deep .rightClass .vxe-body--row.row-modify {
  color: blue !important;
}
::V-deep .rightClass .vxe-body--row.row-HP {
  background-color: RGB(255, 192, 192);
}
::V-deep .rightClass .vxe-body--row.row-E {
  background-color: RGB(219, 112, 147);
}
::V-deep .rightClass .vxe-body--row.row-L {
  background-color: RGB(192, 192, 255);
}
::V-deep .rightClass .vxe-body--row.row-Q {
  background-color: RGB(255, 255, 192);
}

::V-deep .el-button.is-disabled {
  border: 0px;
  color: grey;
  background-color: #e6e6e6;
  font-weight: normal;
}
::V-deep .vxe-header--column.col-blue {
  color: #228b22;
}
</style>
